//
//  CustomOneImageTableViewCell.m
//  WangI
//
//  Created by dllo on 15/11/25.
//  Copyright © 2015年 WJN. All rights reserved.
//

#import "CustomOneImageTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation CustomOneImageTableViewCell

-(void)dealloc {
    [_imageV release];
    [_labelTitle release];
    [_labelDigest release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    [self addSubview:self.imageV];
    [self addSubview:self.labelTitle];
    [self addSubview:self.labelDigest];
    
    [_imageV release];
    [_labelTitle release];
    [_labelDigest release];
    
    return self;
}


#pragma mark -- setDatasource
- (void)setHeaderDataSource:(NSArray *)headerDataSource {
    if (_headerDataSource != headerDataSource) {
        [_headerDataSource release];
        _headerDataSource = [headerDataSource retain];
    }
    
    _labelTitle.text = headerDataSource[0];
    [_imageV sd_setImageWithURL:headerDataSource[1]];
    _labelDigest.text = headerDataSource[2];
}

- (void)setRecerationDataSource:(NSArray *)recerationDataSource {
    if (_recerationDataSource != recerationDataSource) {
        [_recerationDataSource release];
        _recerationDataSource = [recerationDataSource retain];
    }
    
    _labelTitle.text = recerationDataSource[0];
    [_imageV sd_setImageWithURL:recerationDataSource[1]];
    _labelDigest.text = recerationDataSource[2];
}

- (void)setSportDataSource:(NSArray *)sportDataSource {
    if (_sportDataSource != sportDataSource) {
        [_sportDataSource release];
        _sportDataSource = [sportDataSource retain];
    }
    
    _labelTitle.text = sportDataSource[0];
    [_imageV sd_setImageWithURL:sportDataSource[1]];
    _labelDigest.text = sportDataSource[2];
}

- (void)setHotDataSource:(NSArray *)hotDataSource {
    if (_hotDataSource != hotDataSource) {
        [_hotDataSource release];
        _hotDataSource = [hotDataSource retain];
    }
    
    _labelTitle.text = hotDataSource[0];
    [_imageV sd_setImageWithURL:hotDataSource[1]];
    _labelDigest.text = hotDataSource[2];
}

- (void)setFinnaceDataSource:(NSArray *)finnaceDataSource {
    if (_finnaceDataSource != finnaceDataSource) {
        [_finnaceDataSource release];
        _finnaceDataSource = [finnaceDataSource retain];
    }
    
    _labelTitle.text = finnaceDataSource[0];
    [_imageV sd_setImageWithURL:finnaceDataSource[1]];
    _labelDigest.text = finnaceDataSource[2];
}

#pragma mark -- layoutSubviews
-(void)layoutSubviews {
    [super layoutSubviews];
    
    _labelTitle.frame = CGRectMake(5, 5, self.frame.size.width - 10, 20);
    _imageV.frame = CGRectMake(5, 25, self.frame.size.width - 10, self.frame.size.height - 50);
    _labelDigest.frame = CGRectMake(5, _labelTitle.frame.size.height + _imageV.frame.size.height + 10, self.frame.size.width - 10, 20);
}

#pragma mark -- private
-(UIImageView *)imageV {
    if (!_imageV) {
        self.imageV = [[UIImageView alloc] initWithFrame:CGRectZero];
    }
    return _imageV;
}

- (UILabel *)labelDigest {
    if (!_labelDigest) {
        self.labelDigest = [[UILabel alloc] initWithFrame:CGRectZero];
        _labelDigest.font = [UIFont systemFontOfSize:15];
    }
    return _labelDigest;
}

- (UILabel *)labelTitle {
    if (!_labelTitle) {
        self.labelTitle = [[UILabel alloc] initWithFrame:CGRectZero];
        _labelTitle.font =[UIFont boldSystemFontOfSize:18];
    }
    return _labelTitle;
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
